package app.beit.finportal.service.convert;

import java.util.ArrayList;
import java.util.List;

import app.beit.finportal.bean.MenuBean;
import app.beit.finportal.entity.Menu;

public class MenuConvert {

	
	public static MenuBean entityToBean(final Menu entity) throws Exception {
		final MenuBean bean = new MenuBean();
		
		bean.setId(entity.getId());
		bean.setNameTh(entity.getNameTh());
		bean.setNameEn(entity.getNameEn());
		bean.setIsActive(entity.getIsActive());
		bean.setDescription(entity.getDescription());
		bean.setLinkURL(entity.getLinkURL());
		bean.setClassUI(entity.getClassUI());
		bean.setSortBy(entity.getSortBy());
		
		return bean;
	}
	
	
	public static Menu beanToEntity(final MenuBean bean){
		final Menu entity = new Menu();

		entity.setId(bean.getId());
		entity.setNameTh(bean.getNameTh());
		entity.setNameEn(bean.getNameEn());
		entity.setIsActive(bean.getIsActive());
		entity.setDescription(bean.getDescription());
		entity.setLinkURL(bean.getLinkURL());
		entity.setClassUI(bean.getClassUI());
		entity.setSortBy(bean.getSortBy());
		
		return entity;
	}

	
	public static List<MenuBean> entityToBean(final List<Menu> entities) throws Exception{
		final List<MenuBean> beans = new ArrayList<MenuBean>();
		
		for(final Menu entity : entities){
			beans.add(MenuConvert.entityToBean(entity));
		}
		
		return beans;
	}
	

	public static List<Menu> beanToEntity(final List<MenuBean> beans){
		final List<Menu> entities = new ArrayList<Menu>();
		
		for(final MenuBean bean : beans){
			entities.add(MenuConvert.beanToEntity(bean));
		}
		
		return entities;
	}
	
}
